<?php

namespace App\Http\Controllers\Web;

use Illuminate\Http\Request;
use App\WebModels\Feedback;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Response;
use Mockery\Exception;

use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    /*web主页*/
    public function index()
    {
        return view('web/index/index');
    }
    /*发送反馈*/
    public function postFeedback(Request $request){
//        parse_str('data','接收值');
        $ip = $_SERVER['REMOTE_ADDR'];
        $data = $request->all();
        $data['ip'] = $ip;
        $feedback_query = Feedback::query();
        $feedback_query->select();
        $res = DB::insert("INSERT INTO " . Feedback::TABLE_NAME . " (`tel`,`nickname`,`msg`,`ip`) VALUES (?,?,?,?)", [$data['tel'], $data['nickname'], $data['msg'], $data['ip']]);
        if ($res) {
            return $this->message(array(), '发送成功!');
        } else {
            return $this->message(array(), '发送失败!', 500);
        }
    }

}
